package edu.whut;

import java.sql.SQLOutput;
import java.util.Objects;

/*
public boolean equals(Object obj) {
        //谁调方法this就代表谁
        return (this == obj);
        //Object中的equals方法，默认比较的是内存地址
        通常会重写equals方法
    }
---------------------------------------------------------------
Objects继承了Object，常用两个方法
    1.equals
        public static boolean equals(Object a, Object b) {
            return (a == b) || (a != null && a.equals(b));
        }
    2.isNull,ez的
 */
public class EqualsDemo {
    public static void main(String[] args) {
        Student stu1 = null;
        Student stu2 = new Student(1,"周琦");
        System.out.println(stu1 == stu2);//比较地址，false
        //重写equals方法
//       System.out.println(stu1.equals(stu2));

        System.out.println(Objects.equals(stu1, stu2));
        System.out.println("由于Objects我执行到这");
    }
}
